import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/admin/layout/Layout'
import doctorLayout from '../views/doctor/layout/Layout'
import userLayout from '../views/user/layout/Layout'

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
  {path: '/login', component: () => import('@/views/user/login/index'), hidden: true},
  {path: '/adminlogin', component: () => import('@/views/admin/login/index'), hidden: true},
  {path: '/doctorlogin', component: () => import('@/views/doctor/login/index'), hidden: true},

  {path: '/404', component: () => import('@/views/404'), hidden: true},

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/admin/dashboard/index')
    }]
  },

  {
    path: '/admin',
    component: Layout,
    redirect: '/admin/dashboard',
    name: 'dashboard',
    meta: {role: 'admin', title: 'Dashboard', icon: 'dashboard'},
    children: [
      {
        path: 'dashboard',
        name: 'dashboard',
        component: () => import('@/views/admin/dashboard/index'),
        meta: {role: 'admin', title: '首页', icon: 'tree'}
      }
    ]
  },
  {
    path: '/admin/doctor',
    component: Layout,
    redirect: '/admin/doctor/list',
    name: 'admindoctor',
    meta: {role: 'admin', title: '医生管理', icon: 'dashboard'},
    children: [
      {
        path: 'list',
        name: 'doctorlist',
        component: () => import('@/views/admin/doctor/list'),
        meta: {role: 'admin', title: '医生列表', icon: 'teacher'}
      },


    ]
  },
  {
    path: '/admin/user',
    component: Layout,
    redirect: '/admin/user/list',
    name: 'adminuser',
    meta: {role: 'admin', title: '用户管理', icon: 'dashboard'},
    children: [
      {
        path: 'list',
        name: 'userlist',
        component: () => import('@/views/admin/user/list'),
        meta: {role: 'admin', title: '用户列表', icon: 'user'}
      },
    ]
  },
  {
    path: '/admin/hosptial',
    component: Layout,
    redirect: '/admin/hosptial/list',
    name: 'adminhosptial',
    meta: {role: 'admin', title: '医院管理', icon: 'tree'},
    children: [
      {
        path: 'list',
        name: 'hosptiallist',
        component: () => import('@/views/admin/hosptial/list'),
        meta: {role: 'admin', title: '医院列表', icon: 'tree'}
      },
      {
        path: 'add',
        name: 'hosptialadd',
        component: () => import('@/views/admin/hosptial/add'),
        meta: {role: 'admin', title: '添加医院', icon: 'add'}
      },

    ]
  },

  {
    path: '/admin/setting',
    component: Layout,
    redirect: '/admin/setting/index',
    name: 'adminsetting',
    meta: {role: 'admin', title: '设置', icon: 'setting4'},
    children: [
      {
        path: 'index',
        name: 'adminsettingindex',
        component: () => import('@/views/admin/setting/index'),
        meta: {role: 'admin', title: '设置', icon: 'setting4'}
      },
    ]
  },
  // 用户接口
  {
    path: '/user',
    component: userLayout,
    redirect: '/user/index',
    name: 'dashboard',
    meta: {role: 'user', title: 'Dashboard', icon: 'dashboard'},
    children: [
      {
        path: 'index',
        name: 'dashboard',
        component: () => import('@/views/user/index/index'),
        meta: {role: 'user', title: '首页', icon: 'tree'}
      }
    ]
  },
  {
    path: '/user',
    component: userLayout,
    redirect: '/user/index',
    name: 'dashboard',
    meta: {role: 'user', title: 'Dashboard', icon: 'dashboard'},
    children: [
      {
        path: 'yimiao',
        name: 'dashboard',
        component: () => import('@/views/user/yimiao/index'),
        meta: {role: 'user', title: '疫苗接种', icon: 'tree'}
      }
    ]
  },
  {
    path: '/user',
    component: userLayout,
    redirect: '/user/index',
    name: 'dashboard',
    meta: {role: 'user', title: 'Dashboard', icon: 'dashboard'},
    children: [
      {
        path: 'jibing',
        name: 'dashboard',
        component: () => import('@/views/user/jibing/index'),
        meta: {role: 'user', title: '疾病预测', icon: 'tree'}
      }
    ]
  },


  // 医生接口
  {
    path: '/doctor',
    component: doctorLayout,
    redirect: '/doctor/index',
    name: 'doctorindex',
    meta: {role: 'doctor', title: 'Dashboard', icon: 'dashboard'},
    children: [
      {
        path: 'index',
        name: 'doctorindexpage',
        component: () => import('@/views/doctor/index/index'),
        meta: {role: 'doctor', title: '首页', icon: 'tree'}
      }
    ]
  },
  {
    path: '/doctor',
    component: doctorLayout,
    redirect: '/doctor/index',
    name: 'doctorjibing',
    meta: {role: 'doctor', title: 'Dashboard', icon: 'dashboard'},
    children: [
      {
        path: 'jibing',
        name: 'doctorjibingpage',
        component: () => import('@/views/doctor/jibing/index'),
        meta: {role: 'doctor', title: '疾病预测', icon: 'tree'}
      }
    ]
  },
  {path: '*', redirect: '/404', hidden: true}
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})

